import { type NextRequest, NextResponse } from "next/server"
import type { ApiResponse } from "@/types"

// 配置为静态路由以支持静态导出
export const dynamic = 'force-static'

export async function GET(request: NextRequest) {
  try {
    // 验证token
    const token = request.headers.get("authorization")?.replace("Bearer ", "")
    if (!token) {
      return NextResponse.json({ success: false, message: "未授权" }, { status: 401 })
    }

    // 这里应该调用真实的后端API
    // const response = await fetch('http://localhost:8081/api/samples/stats', {
    //   headers: { Authorization: `Bearer ${token}` }
    // })
    // const result = await response.json()
    // return NextResponse.json(result)

    // 临时模拟数据，实际项目中应该删除
    const stats = {
      total: 67,
      unassigned: 25,
      mixedOnly: 18,
      mixedGroups: 12,
      samplingGroups: 4,
    }

    const response: ApiResponse<typeof stats> = {
      success: true,
      data: stats,
      message: "", // 添加必填的message属性
    }

    return NextResponse.json(response)
  } catch (error) {
    return NextResponse.json({ success: false, message: "服务器错误" }, { status: 500 })
  }
}
